//
//  LoopBaseViewController.swift
//  LoopWeibo
//
//  Created by loop安 on 2016/12/8.
//  Copyright © 2016年 loop. All rights reserved.
//

import UIKit

class LoopBaseViewController: UIViewController,LoopVisitorLoginViewDelegate {

    //定义一个变量,用以记录用户是否登录
    var isload = LoopUserAccountViewModel.shared.userLogin
    
    lazy var visitorV:LoopVisitorLoginView = LoopVisitorLoginView()
    
    override func loadView() {
        //在loadView方法中判断用户是否已登录
        //登录显示正确视图
        //未登录,显示登录视图
        if isload{
            
        super.loadView()
            
        }else{
        
            self.view = visitorV
            visitorV.delegate = self
        
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        if isload{
            setupUI()
        }
    }

    //登录按钮的点击事件
    func visitorWillLogin() {
        print(#function)
        let loginView = LoopOAuthViewController()
        let nav = LoopNaviController(rootViewController: loginView)
        //model一个控制器,用以显示登录授权界面
        present(nav, animated: true, completion: nil)
        
    }
    
    func visitorWillRegist() {
        print(#function)
    }

    func setupUI(){
    
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
